package com.xiaozhengkeji.blogsuper.services.bus.impl;

import com.google.gson.Gson;
import com.xiaozhengkeji.blogsuper.base.entitys.UserEntity;
import com.xiaozhengkeji.blogsuper.base.service.UserEntityService;
import com.xiaozhengkeji.blogsuper.services.bus.UserServiceBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service("UserServiceBus")
public class UserServiceBusIMP implements UserServiceBus {
    @Autowired
    UserEntityService userEntityService;
    @Override
    public int register(String username, String emailBox, String password, String regIP) {
        UserEntity userEntity = new UserEntity();
        userEntity.setUserName(username);
        userEntity.setEMailBox(emailBox);
        userEntity.setPassWord(password);
        userEntity.setRegIp(regIP);
        userEntity.setEndLoginIp(regIP);
        userEntity.setUserState(1);
        List<String> per = new LinkedList<>();
        per.add("user:def");
        userEntity.setPermission(new Gson().toJson(per));
        return userEntityService.insert(userEntity);
    }
}
